package com.hkbigdata.transform;

import org.apache.flink.streaming.api.datastream.KeyedStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author liuanbo
 * @creat 2023-03-19-10:19
 * @see 2194550857@qq.com
 */
public class Flink08_TransFrom_max_sum_min {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setParallelism(1);


        KeyedStream<Integer, String> source = env.fromElements(1,9 ,3, 5, 8)
                .keyBy(data -> data % 2 == 0 ? "奇数" : "偶数");

        source.sum(0).print("sum");
        source.max(0).print("max");
        source.min(0).print("min");
        env.execute();
    }
}
